package com.yang.studentsapp;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

/**
 * Created by ${Ян-Вэнь-Чао} on 2016/10/13.
 */
public  abstract class BaseSociety implements AdapterClickBack{
    protected CampusSociety mSociety;
    protected Context mContext;
    protected View mConvertView;
    protected ViewHolder mViewHolder;

    public BaseSociety(CampusSociety society, Context context) {
        mSociety = society;
        mContext = context;
        LayoutInflater inflater = LayoutInflater.from(context);
        mConvertView = inflaterLayout(inflater);
        mViewHolder = new ViewHolder(this, mConvertView);
        setListener(mViewHolder);

        setTag();
    }

    public void setSociety(CampusSociety society) {
        mSociety = society;
    }

    protected abstract View inflaterLayout(LayoutInflater inflater);


    protected abstract void setListener(ViewHolder viewHolder);


    public void setPosition(int position){
        mViewHolder.setPosition(position);
    }
    private void setTag() {
        if(mConvertView != null){
            mConvertView.setTag(this);
        }
    }
    public BaseSociety getTag() {
        return (BaseSociety) mConvertView.getTag();
    }

    public void setData(CampusSociety society){
        mViewHolder.setText(society.getTitle(), R.id.item_title_tv)
                .setText(society.getTime()+"",R.id.item_time_tv)
                .setText("1234",R.id.item_see_num);
    }

    public View getConvertView() {
        return mConvertView;
    }
}
